<?php

/*
 * @author:Tham
 * Conect database with booking deal 
 */

class BookingDeal {
    /*
     * Add more booking on databasa
     * @param array $data
     * 
     */

    public static function AddBookingDeal($data) {
        global $wpdb;
        $sql = 'INSERT INTO `travel_deal_flight_booking`(`user_book`, `deal_flight_id`, `create_time`,type_travel) 
	    VALUES(' . $data['user_book'] . ',' . $data['deal_flight_id'] . ', ' . time() . ',' . $data['type_travel'] . ')';
        //   echo $sql;
        $wpdb->query($sql);
    }

    /*
     * Check user has alreadu book deal
     * @param array $data
     */

    public static function checkBookDeal($data) {

        global $wpdb;
        $sql = " SELECT count(`deal_flight_booking_id`) totalrows FROM `travel_deal_flight_booking` "
                . " WHERE `deal_flight_id`=" . $data['deal_flight_id'] . " and `user_book`=" . $data['user_book'];
        $data = $wpdb->get_results($sql);
        return $data;
    }

}
